home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / 8bit / cislib_a / ciolib.pas < prev    next >
Pascal/Delphi Source File  |  1995-04-22  |  3KB  |  127 lines

  1. (*             CIOLib.i 
  2.                ________ 
  3.        (C) 1986  Erik C. Warren 
  4.     Routines to access CIO calls. 
  5. Last Updated:  30 July, 1986 
  6.   These routines are in the public 
  7. domain and may not be sold, except for 
  8. the price of the software media, with- 
  9. out the expressed, written permission 
  10. of the author.                       *) 
  11.  
  12. FUNCTION Close(IOCB_Num: Integer): Integer; 
  13. BEGIN 
  14.  Close:= 1; 
  15.  IOCB_Num:= IOCB_Num * 16; 
  16. #A 
  17.   stx _t 
  18.   ldy #7 
  19.   lda (_sp),y  ;IOCB 
  20.   tax 
  21.   lda #12      ;close command 
  22.   sta $342,x 
  23.   jsr $e456    ;ciov 
  24.   tya          ;same as icsta 
  25.   ldy #5 
  26.   sta (_sp),y  ;store in Close 
  27.   ldx _t 
  28. END;(* Close *) 
  29.  
  30. FUNCTION Open(IOCB_Num,Ax1,Ax2: Integer;               VAR Dev: Device_String) 
  31.              : Integer; 
  32. BEGIN 
  33.  Open:= 1; 
  34.  IOCB_Num:= IOCB_Num * 16; 
  35. (*  stack: opn  num  ax1  ax2  dev   
  36.             5    13   11   9    7    *) 
  37. #A 
  38.  stx _t 
  39.  ldy #13 
  40.  lda (_sp),y  ;IOCB 
  41.  tax 
  42.  lda #3       ;open command 
  43.  sta $342,x 
  44.  dey  
  45.  dey          ;11 
  46.  lda (_sp),y  ;icax1 
  47.  sta $34a,x 
  48.  dey 
  49.  dey          ;9 
  50.  lda (_sp),y  ;icax2 
  51.  sta $34b,x 
  52.  dey          ;8 
  53.  lda (_sp),y  ;dev MSB 
  54.  sta $345,x   ;icbah 
  55.  dey          ;7 
  56.  lda (_sp),y  ;icbal 
  57.  sta $344,x 
  58.  jsr $e456    ;ciov 
  59.  tya          ;same as icsta 
  60.  ldy #5 
  61.  sta (_sp),y  ;store in Open 
  62.  ldx _t 
  63. END;(* Open *) 
  64.  
  65. FUNCTION Get_Byte(IOCB_Num: Integer; 
  66.                     VAR GB: Integer) 
  67.                  : Integer; 
  68. VAR TB: Integer; 
  69. BEGIN 
  70.  TB:= 0; 
  71.  Get_Byte:= 1; 
  72.  GB:= 0; 
  73.  IOCB_Num:= IOCB_Num * 16; 
  74. (*  stack: get  num   gb   tb 
  75.            7/8 11/12 9/10 5/6      *) 
  76. #A 
  77.  stx _t 
  78.  ldy #11 
  79.  lda (_sp),y  ;IOCB 
  80.  tax 
  81.  lda #7       ;get char command 
  82.  sta $342,x 
  83.  lda #$00     ;zero out the unused 
  84.  sta $348,x   ;store in accumulator 
  85.  sta $349,x   ;...after CIOV jump 
  86.  jsr $e456 
  87.  sty _t+1     ;hold temporarily 
  88.  ldy #5 
  89.  sta (_sp),y  ;put byte in GB 
  90.  lda _t+1     ;get status back 
  91.  ldy #7 
  92.  sta (_sp),y  ;store in Get_Byte 
  93.  ldx _t 
  94. GB:= TB 
  95. END;(* Get_Byte *) 
  96.  
  97. FUNCTION Put_Byte(IOCB_Num: Integer; 
  98.                         PB: Integer) 
  99.                  : Integer; 
  100. BEGIN 
  101.  Put_Byte:= 1; 
  102.  IOCB_Num:= IOCB_Num * 16; 
  103. (*  stack: put  num   pb 
  104.             5    9    7            *) 
  105. #A 
  106.  stx _t 
  107.  ldy #9 
  108.  lda (_sp),y  ;IOCB 
  109.  tax 
  110.  lda #11      ;put char command 
  111.  sta $342,x 
  112.  lda #$00     ;zero out the unused 
  113.  sta $348,x   ;put from accumulator 
  114.  sta $349,x 
  115.  ldy #7 
  116.  lda (_sp),y  ;put PB in accumulator 
  117.  jsr $e456 
  118.  tya          ;same as icsta 
  119.  ldy #5 
  120.  sta (_sp),y  ;store in Put_Byte 
  121.  ldx _t 
  122. END;(* Put_Byte *) 
  123.